﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.lmpop.createIndex.search.*" %>
<%@ page import="com.lmpop.trade.ti_address.*" %>
<%@ page import="com.lmpop.trade.ts_area.*" %>
<%@ page import="com.lmpop.frame.util.PageUtil" %>
<%@ page import="com.lmpop.frame.util.RandomID" %>
<%@ page import="com.lmpop.createIndex.search.*" %>
<%
    
	request.setCharacterEncoding("UTF-8");
	String g_addr_id = new RandomID().GenTradeId();
	
	String user_id = "",cust_id="";	
	if( session.getAttribute("session_user_id") != null ){
		user_id = session.getAttribute("session_user_id").toString().trim();
	}
	if( session.getAttribute("session_cust_id") != null ){
		cust_id = session.getAttribute("session_cust_id").toString().trim();
	}

	Ti_addressInfo ti_addressInfo = new Ti_addressInfo();
	AreaIndexFiles areaBean = new AreaIndexFiles();
	int limit = 2;
	int start = 0;
	int startPage =1;
	if(request.getParameter("start") != null && !request.getParameter("start").equals(""))
	{
		start = Integer.parseInt(request.getParameter("start"));
	}
	if(start>1) 
	{
		startPage = start;
	}
	
	Map addrMap = new Hashtable();
	addrMap.put("user_id",user_id);
	
	List addrlist = ti_addressInfo.getListByPage(addrMap,start,limit);
	int counter = ti_addressInfo.getCountByObj(addrMap);
	
    PageUtil pageUtil = new PageUtil("","<li class=up>[uppage/]</li>","<li class=next>[downpage/]</li>","","","<li class=pages_h>[num/]</li>","<li class=pages>[thisnum/]</li>");
	String pageString = pageUtil.getPageString("confirm_order_address.jsp",counter,limit,startPage,request);
	
	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>配送地址</title>
<link href="/templets/html/shop/css/mall_top.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/add.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/mall_bottom.css" rel="stylesheet" type="text/css" />
<link href="/templets/html/shop/css/style.css" rel="stylesheet" type="text/css" />
<link  href="/templets/html/shop/css/Home.css" rel="stylesheet"/>
<SCRIPT type='text/javascript' src="/templets/html/shop/js/order_address.js"></SCRIPT>
<SCRIPT src="/templets/html/shop/js/taobao.js"></SCRIPT>
<SCRIPT src="/templets/html/shop/js/nav_style_num.js"></SCRIPT>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js'></script>
<script type='text/javascript' src='/dwr/engine.js'></script>
<script type='text/javascript' src='/dwr/util.js'></script>
<script type='text/javascript' src='/dwr/interface/Ti_subscribeInfo.js'></script>
<script type='text/javascript' src='/templets/html/shop/js/_shop.js'></script>
</head>
<body>
<div class="clearfix">
<!--导航开始-->
<div >
<div>
  <script> 
  document.write("<s" + "cript type='text/javascript' src='/templets/html/shop/top.jsp?" + Math.random() + "'></scr" + "ipt>"); 
  TB.Header.init(); 
</script>
  <!--导航结束-->
  <div class="clear"></div>
  <!--当前位置开始-->
  <!--当前位置结束-->
  <div class="clear"></div>
  <!--提交订单开始-->
  <div class="clear"></div>
  <!--提交订单结束-->
  <div class="content0">
    <div class="chengxu">
      <div class="chengxu_m">
        <ul>
          <li class="txt_li">登录/注册<small>login/regist</small><img align="absmiddle" src="/templets/html/shop/images/jiantou.gif" /></li>
          <li class="txt_li">我的购物车<small>shopping cart</small><img align="absmiddle" src="/templets/html/shop/images/jiantou_l.gif" /></li>
          <li class="tex_current">填写订单信息<small>order information</small><img align="absmiddle" src="/templets/html/shop/images/jiantou_r.gif" /></li>
          <li class="txt_li">提交订单,付款<small>submit/pay</small><img align="absmiddle"src="/templets/html/shop/images/jiantou.gif" /></li>
          <li class="txt_li">等待收货<small>wait for delivery</small></li>
        </ul>
      </div>
    </div>
    <div class="content grid-c">
      <%
	  int addrlistsize = 0;
	  if(addrlist!=null && addrlist.size()>0){
			addrlistsize = addrlist.size();
	
	%>
      <div class="add_c">
        <div class="add_c_h">
          <h1><b>地址簿</b> （您以前用过的地址）</h1>
        </div>
        <div class="add_ps">
          <%
			    for(int i=0;i<addrlistsize;i++){
				
					Hashtable map = (Hashtable)addrlist.get(i);
					String addr_id="",consignee="",infolevel="",email="",area_attr="",address="",post_code="",tel="",cellphone="";
					String sign_building="",best_time="",v_user_id="",in_date="";		  			
					if(map.get("addr_id")!=null) addr_id = map.get("addr_id").toString();
					if(map.get("consignee")!=null) consignee = map.get("consignee").toString();
					if(map.get("infolevel")!=null) infolevel = map.get("infolevel").toString();
					if(map.get("email")!=null) email = map.get("email").toString();
					if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
					if(map.get("address")!=null) address = map.get("address").toString();
					if(map.get("post_code")!=null) post_code = map.get("post_code").toString();
					if(map.get("tel")!=null) tel = map.get("tel").toString();
					if(map.get("cellphone")!=null) cellphone = map.get("cellphone").toString();
					
					String areaoutput="";
					if(!area_attr.equals(""))
					{
					   String areaArr[] = area_attr.split("\\|");
					   for( int k = 0; k < areaArr.length; k++)
					   {
						  if( k == areaArr.length-1)
						  {
							   areaoutput +=  areaBean.getAreaNameById(areaArr[k]);	 		
						  }
						  else
						  {
							   areaoutput +=  areaBean.getAreaNameById(areaArr[k])+ "-";
						  }		   		
					   }
					}
					
					//拼接 详细地址
					address = areaoutput.replace("-","")+ address;
					
					String className ="";
					if(i==0){className ="add_left";}
				    else {className = "add_rig";}
				
			%>
          <div class="<%=className%>">
            <ul>
              <li>收 货 人：<%=consignee%></li>
              <li>地　　区：<%=areaoutput%></li>
              <li>收货地址： <%=address%> </li>
              <li>邮政编码：<%=post_code%></li>
              <li>固定电话：<%=tel%></li>
              <li>移动电话：<%=cellphone%></li>
            </ul>
            <p> <a href="#addr"  onclick="javascript:ModifyAddr('<%=consignee%>','<%=area_attr%>','<%=address%>','<%=post_code%>','<%=tel%>','<%=cellphone%>','<%=addr_id%>');">修改</a> | <a href="/doTradeReg.do?pkid=<%=addr_id%>&bpm_id=1030">删除</a> <span><a href="###" onclick="setAddress('<%=consignee%>','<%=area_attr%>','<%=address%>','<%=post_code%>','<%=tel%>','<%=cellphone%>')"><img src="/templets/html/images/dd_29.jpg" /></a></span></p>
          </div>
          <%
			   }
			%>
          <div class="clear"></div>
        </div>
        <div>
          <ul class="next_ul">
            <%=pageString%>
          </ul>
        </div>
      </div>
      <%
	
	  }
	%>
      <div class="add_c m_top">
        <!-- <div class="add_c_h">
          <h1>请输入新的 <b>配送地址</b></h1>
        </div> -->
        <form action="/doTradeReg.do" method="post" name="addrForm"/>
        <!--确认收货地址开始-->
        <div class="shdz">
          <ul>
            <li class="dz_name"><font>收货人姓名：</font>
              <input name="consignee" id="consignee" type="text" maxlength="50" onchange="ChecktheForm_Name()" class="input_area_n"/>
              &nbsp;<span>*</span>&nbsp;<b>请准确填写真实姓名，以便确保商品准确无误送达。</b> </li>
            <li style="position:absolute;display:none" id="consignee_ck">
              <div class="add_ok">请输入正确的姓名</div>
            </li>
            <li class="dz_ad"><font>配送省份/直辖市：</font>
              <select name="province" id="province" onclick="setCitys(this.value)" onchange="ChecktheForm_PCA()">
                <option>--请选择--</option>
              </select>
              &nbsp;市：
              <select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)" onchange="ChecktheForm_PCA()">
                <option>--请选择--</option>
              </select>
              &nbsp;县/区：
              <select name="city_code" id="city_code" onchange="ChecktheForm_PCA()">
                <option>--请选择--</option>
              </select>
              &nbsp;<span>*</span>&nbsp; </li>
            <script>
					   setProvince();
					</script>
            <li style="position:absolute;display:none" id="address_ck">
              <div class="add_err" id="address_error_name">请选择省份/直辖市</div>
            </li>
            <li class="dz_xad"><font>详细地址：</font>
              <input name="address" id="address"  type="text" size="37"  maxlength="100" onchange="ChecktheForm_Address()" class="input_area_n"/>
              &nbsp;<span>*</span><br />
            </li>
            <li class="dz_xd">部分城市支持货到付款。&nbsp;&nbsp;&nbsp;&nbsp;</li>
            <li style="position:absolute;display:none;" id="detail_addr">
              <div class="add_err">请输入详细地址</div>
            </li>
            <li class="dz_xx"><font>邮政编码：</font>
              <input name="post_code" id="post_code"  type="text" size="9" maxlength="6" onchange="ChecktheForm_Zip()" class="input_area_n"/>
              &nbsp;<span>*</span> </li>
            <li style="position:absolute;display:none;" id="post_code_ck">
              <div class="add_err" id="post_error_name">请输入邮政编码</div>
            </li>
            <li class="dz_xx"><font>固定电话：</font>
              <input name="tel" id="tel" type="text" size="22" maxlength="30" class="input_area_n"/>
              &nbsp;&nbsp;<b>固定电话格式：0512-53703175</b></li>
            <li class="dz_ph"><font>手　　机：</font>
              <input name="cellphone" id="cellphone"  type="text" size="22" maxlength="11" class="input_area_n"/>
              &nbsp;&nbsp;<b>手机与固定电话必须有一项必填</b></li>
            <li style="position:absolute;display:none;" id="contact_ck">
              <div class="add_err" id="contact_error_name">请输入联系方式</div>
            </li>
            <li class="dz_an"><a href="javascript:Check_ConsigneeForB2c();"><img src="/templets/html/shop/images/dd_26.jpg" /></a></li>
          </ul>
        </div>
        <!--确认收货地址结束-->
        <input type="hidden" name="area_attr" id="area_attr" value="" />
        <input type="hidden" name="addr_id" id="g_addr_id" value="<%=g_addr_id%>" />
        <input type="hidden" name="user_id" id="user_id" value="<%=user_id%>" />
        <input type="hidden" name="cust_id" id="cust_id" value="<%=cust_id%>" />
        <input type="hidden" name="jumpurl" value="/templets/html/shop/jsp/confirm_again_address.jsp" />
        <input type="hidden" name="bpm_id" id="bpm_id" value="5675" />
        </form>
        <div class="add_c_f">
          <h2>接下来您还需要选择 配送方式、支付方式、送货时间。</h2>
        </div>
      </div>
    </div>
  </div>
  <!--广告开始-->
  <div class="commitment">
    <div class="commitment_left">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_1.jpg" /></a></div>
      <div class="commitment_txt">
        <p><span class="commitment_txt1">全国900个城市货到付款</span><span class="commitment_txt2"></span></p>
      </div>
    </div>
    <div class="commitment_center">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_2.jpg" /></a></div>
      <div class="commitment_txt3">
        <p><span class="commitment_txt1">购买满200免运费</span><span class="commitment_txt2"></span></p>
      </div>
    </div>
    <div class="commitment_right">
      <div class="commitment_pic"><a href=""><img src="/templets/html/shop/images/commitment_3.jpg" /></a></div>
      <div class="commitment_txt4">
        <p><span class="commitment_txt1">30天无忧退换货</span><span class="commitment_txt2"></span><span class="commitment_txt1">保障</span></p>
      </div>
    </div>
  </div>
  <!--广告结束-->
  <div class="clear"></div>
  <!--底部开始-->
  <jsp:include page="/templets/html/shop/footer.jsp"/>
  <!--底部结束-->
</div>
<form action="/templets/html/shop/jsp/confirm_again_address.jsp" method="post" name="putForm"/>
<input type="hidden" name="area_attr" id="put_area_attr" value="" />
<input type="hidden" name="consignee" id="put_consignee" value="" />
<input type="hidden" name="post_code" id="put_post_code" value="" />
<input type="hidden" name="tel" id="put_tel" value="" />
<input type="hidden" name="cellphone" id="put_cellphone" value="" />
<input type="hidden" name="address" id="put_address" value="" />
</form>
</body>
</html>
